package com.sip.stream.utils.zfy.holder;


import android.os.Build;
import android.view.View;

import com.sip.stream.ClientApp;
import com.sip.stream.R;
import com.sip.stream.databinding.ViewholderStatusBatteryBinding;
import com.sip.stream.utils.zfy.adapter.BaseDataBindingViewHolder;
import com.sip.stream.utils.zfy.listener.DataBindingViewHolderClickListener;
import com.sip.stream.utils.zfy.status.ZFYStatus;

public class ZFYStatusBatteryViewHolder extends BaseDataBindingViewHolder<ViewholderStatusBatteryBinding, String> {
    public ZFYStatusBatteryViewHolder(ViewholderStatusBatteryBinding viewholderStatusBatteryBinding, DataBindingViewHolderClickListener<String> dataBindingViewHolderClickListener) {
        super(viewholderStatusBatteryBinding, dataBindingViewHolderClickListener);
    }

    @Override
    public void onBindViewHolder(int i, String str) {
        super.onBindViewHolder(i, str);
        int batteryLevel = ZFYStatus.getInstance().getBatteryLevel();
        this.binding.tvMessage.setText(batteryLevel + "%");
        if (ZFYStatus.getInstance().isPowerconnected()) {
            this.binding.ivPowerconnect.setVisibility(View.VISIBLE);
            this.binding.pbPower.setVisibility(View.GONE);
            return;
        }
        this.binding.pbPower.setVisibility(View.VISIBLE);
        this.binding.ivPowerconnect.setVisibility(View.GONE);
        if (batteryLevel < 11) {
            this.binding.pbPower.setBackground(ClientApp.clientApp.getResources().getDrawable(R.drawable.ic_vector_battery_low));
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                this.binding.pbPower.setProgress(0, false);
            }
            this.binding.pbPower.setSecondaryProgress(batteryLevel);
            return;
        }
        this.binding.pbPower.setBackground(ClientApp.clientApp.getResources().getDrawable(R.drawable.ic_vector_battery_normal));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            this.binding.pbPower.setProgress(batteryLevel, false);
        }
        this.binding.pbPower.setSecondaryProgress(0);
    }
}
